package com.itheima.Test07;

import java.util.ArrayList;

public class StudentServiceImpl1 implements StudentService {

    @Override
    public void printAllinfo(ArrayList<Student> students) {
        System.out.println("-------------全班全部学生如下----------");
        //遍历获取每个学生
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            System.out.println("姓名："+s.getName()+",性别:"+s.getSex()+",成绩:"+s.getScore());
        }
        System.out.println("-----------------------------------");
    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        double allscore =0.0;
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            //全部成绩总和
            allscore +=s.getScore();
        }
        System.out.println("平均分:"+allscore/students.size());
    }
}
